<h1>Автомобили</h1>

<p style="margin-bottom: 8px;">
<a href="/cars/add/">
    <img alt="" src="<?=$this->staticUrl()?>/img/bluearrow.gif" />
    Добавяне на автомобил
</a>
</p>

<table class="simple" style="width: 98%;">
    <thead>
        <tr>
            <td colspan="10">
                <form action="/cars/" method="get">
                    <div>
                    Филтър:
                    <input type="text" name="keyword" value="<?=$this->keyword ? $this->keyword : 'Ключова дума';?>" />
                    <?=$this->formSelect('make_id', $this->make_id, null, $this->makes)?>
                    <?=$this->formSelect('year_from', $this->year_from, null, $this->years)?>
                    <?=$this->formSelect('year_to', $this->year_to, null, $this->years)?>
                    <input type="submit" value="Търси" style="width: 120px;" />
                    <a href="/cars/">Изчисти</a>
                    </div>
                </form>
            </td>
        </tr>
        <? if (count($this->items)): ?>
        <tr>
            <th>ID</th>
            <th>Макра</th>
            <th>Модел</th>
            <th>Цена (лв)</th>
            <th>Година</th>
            <th>Пробег (км)</th>
            <th></th>
        </tr>
        <? endif ?>
    </thead>

    <tbody>
    <? if (count($this->items)): ?>

        <? foreach ($this->items as $item): ?>
        <tr>
            <td class="ids"><?=$item['id']?></td>
            <td><a href="/cars/edit/id/<?=$item['id']?>"><?=$this->escape($item['make_name'])?></a></td>
            <td><a href="/cars/edit/id/<?=$item['id']?>"><?=$this->escape($item['model'])?></a></td>
            <td><?=$this->escape($item['price'])?></td>
            <td><?=$this->escape($item['produced'])?></td>
            <td><?=$this->escape($item['kms'])?></td>
            <td class="action">
                <a href="/cars/edit/id/<?=$item['id']?>">
                    <img class="action" alt="edit" title="Редакция" src="<?=$this->staticUrl()?>/img/edit.gif" />
                </a>
                <a href="/cars/remove/id/<?=$item['id']?>" onclick="return window.confirm('Сигурни ли сте?');">
                    <img class="action" alt="remove" title="Изтриване" src="<?=$this->staticUrl()?>/img/remove.gif" />
                </a>
            </td>
        </tr>
        <? endforeach ?>

    <? else: ?>

        <tr><td colspan="10">
            Няма резултати
        </td></tr>

    <? endif ?>
    </tbody>

</table>

<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
    $('input[@name=keyword]').focus(function() {
        if ($(this).val() == 'Ключова дума') {
            $(this).val('');
        }
    })
});
//]]>
</script>